package com.woniuxy.service.aspect;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class Aspect implements MethodInterceptor {
    public void log(){
        System.out.println("日志开始打印");
    }
    public void commitTransation(){
        System.out.println("事务提交");
    }

    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        log();
        Object proceed = invocation.proceed();
        commitTransation();
        return proceed;
    }
}
